import { Component, Host, h, ComponentInterface } from '@stencil/core';
// import * as tf from '@tensorflow/tfjs';
import * as tfvis from '@tensorflow/tfjs-vis';

@Component({
  tag: 'linear-regression',
  styleUrl: 'linear-regression.css',
  shadow: true,
})
export class LinearRegression implements ComponentInterface {

  componentDidLoad(): void {
    const xs = [1, 2, 3, 4];
    const ys = [1, 3, 5, 7];
    tfvis.render.scatterplot({ name: '线性回归', }, {
      values: xs.map((x: number, i: number) => {
        return { x, y: ys[i] }
      }),
    }, { xAxisDomain: [0, 5], yAxisDomain: [0, 8] });
  }

  render() {
    return (
      <Host>
        <div></div>
      </Host>
    );
  }

}
